package com.mi.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mi.entity.*;
import com.mi.mapper.Service_supportMapper;
import com.mi.service.Service_PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class Service_supportImpl implements Service_PointService {

    @Autowired(required = false)
    Service_supportMapper service_supportMapper;

    /**
     * 查询服务网点
     * @return
     */
    @Override
    public List<ServicePointEntity> queryServicePoint() {

        return service_supportMapper.queryServicePointMapper();
    }

    /**
     * 添加维修
     * @param repairEntity
     * @return
     */
    @Override
    public boolean insertRepair(RepairEntity repairEntity) {
        return service_supportMapper.insertRepairMapper(repairEntity);
    }

    /**
     * ；调用mapper
     * @param dataRequestEntity
     * @return
     */
    @Override
    public boolean insertDataRequest(DataRequestEntity dataRequestEntity) {
        return service_supportMapper.insertDataRequestMapper(dataRequestEntity);
    }

    @Override
    public boolean insertComplaintSuggestService(ComplaintSuggestEntity complaintSuggestEntity) {
        return service_supportMapper.insertComplaintSuggestMapper(complaintSuggestEntity);
    }

    /**
     * 查询维修服务
     * @param repairEntity
     * @return
     */
    public MyPages<RepairEntity> queryRepairs(RepairEntity repairEntity){
        PageHelper.startPage(repairEntity.getPageNum(),repairEntity.getPageSize());
        List<RepairEntity> repairEntities = service_supportMapper.queryRepairs(repairEntity);
        PageInfo<RepairEntity> pageInfo = new PageInfo<>(repairEntities);
        MyPages<RepairEntity> repairEntityMyPages = new MyPages<>();
        repairEntityMyPages.setList(pageInfo.getList());
        repairEntityMyPages.setPageNum(pageInfo.getPageNum());
        repairEntityMyPages.setPageSize(pageInfo.getPageSize());
        repairEntityMyPages.setPages(pageInfo.getPages());
        repairEntityMyPages.setPageCount((int)pageInfo.getTotal());
        return repairEntityMyPages;
    }

    /**
     * 删除微信服务
     * @param ids
     * @return
     */
    public boolean delRepair( String[] ids){
        return service_supportMapper.delRepair(ids);
    }

    /**
     * 查询资料索取
     * @param dataRequestEntity
     * @return
     */
    public MyPages<DataRequestEntity> queryDataRequests(DataRequestEntity dataRequestEntity){
        PageHelper.startPage(dataRequestEntity.getPageNum(),dataRequestEntity.getPageSize());
        List<DataRequestEntity> dataRequestEntities = service_supportMapper.queryDataRequests(dataRequestEntity);
        PageInfo<DataRequestEntity> pageInfo = new PageInfo<>(dataRequestEntities);
        MyPages<DataRequestEntity> dataRequestEntityMyPages = new MyPages<>();
        dataRequestEntityMyPages.setList(pageInfo.getList());
        dataRequestEntityMyPages.setPageNum(pageInfo.getPageNum());
        dataRequestEntityMyPages.setPageSize(pageInfo.getPageSize());
        dataRequestEntityMyPages.setPages(pageInfo.getPages());
        dataRequestEntityMyPages.setPageCount((int)pageInfo.getTotal());
        return dataRequestEntityMyPages;
    }

    /**
     * 删除资料索取
     * @param ids
     * @return
     */
    public boolean delDataRequest( String[] ids){
        return service_supportMapper.delDataRequest(ids);
    }


    /**
     * 查询投诉建议
     * @param complaintSuggestEntity
     * @return
     */
    public MyPages<ComplaintSuggestEntity> queryComplaintSuggests(ComplaintSuggestEntity complaintSuggestEntity){
        PageHelper.startPage(complaintSuggestEntity.getPageNum(),complaintSuggestEntity.getPageSize());
        List<ComplaintSuggestEntity> complaintSuggestEntities = service_supportMapper.queryComplaintSuggests(complaintSuggestEntity);
        PageInfo<ComplaintSuggestEntity> pageInfo = new PageInfo<>(complaintSuggestEntities);
        MyPages<ComplaintSuggestEntity> ComplaintSuggestMyPages = new MyPages<>();
        ComplaintSuggestMyPages.setList(pageInfo.getList());
        ComplaintSuggestMyPages.setPageNum(pageInfo.getPageNum());
        ComplaintSuggestMyPages.setPageSize(pageInfo.getPageSize());
        ComplaintSuggestMyPages.setPages(pageInfo.getPages());
        ComplaintSuggestMyPages.setPageCount((int)pageInfo.getTotal());
        return ComplaintSuggestMyPages;
    }

    /**
     * 删除投诉建议
     * @param ids
     * @return
     */
    public boolean delComplaintSuggest(String[] ids) {
        return service_supportMapper.delComplaintSuggest(ids);
    }
    /**
     * 查询合作伙伴
     * @return
     */
    @Override
    public MyPages<PartnerEntity> queryPartnerService(PartnerEntity pt) {
        PageHelper.startPage(pt.getPageNum(),pt.getPageSize());
        List<PartnerEntity> list = service_supportMapper.queryPartnerMapper(pt);
        PageInfo<PartnerEntity> pageInfo = new PageInfo<>(list);
        MyPages<PartnerEntity> partPages = new MyPages<>();
        partPages.setList(pageInfo.getList());
        partPages.setPageNum(pageInfo.getPageNum());
        partPages.setPageSize(pageInfo.getPageSize());
        partPages.setPages(pageInfo.getPages());
        partPages.setPageCount((int) pageInfo.getTotal());
        return partPages;
    }


}
